package edu.sctu.jarime.june.day20150607.suitang;

/**
 * Created by Jarime on 2015/6/7.
 */
public class StageThread extends Thread{
    public void run(){
        System.out.println("隋唐英雄传大戏马上开始，请保持安静");
        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println("舞台拉开大幕");

        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

        AmyRunnable suiAmy=new AmyRunnable();
        AmyRunnable nongAmy=new AmyRunnable();

        Thread Amyofsui=new Thread(suiAmy,"隋军");
        Thread Amyofnong=new Thread(nongAmy,"农民起义军");
        //里面的参数是放的一个Runnable类型的对象和对象的名称
        Amyofnong.start();
        Amyofsui.start();

        try {
            Thread. sleep(5000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }


        System.out.println("正当战争激烈之时，英雄人物MrChen出现了...");

        Thread MrChen=new MajorPeopleThread();
        MrChen.setName("Mrchen");
        //停止进队战争
        //停止线程
        suiAmy.keepruning=false;
        nongAmy.keepruning=false;

        try {
            Thread.sleep(2000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

        MrChen.start();
        try {
            MrChen.join(3000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }


        System.out.println("谢谢观看");



    }

    public static void main(String[] args) {

        new StageThread().start();
    }

}
